﻿// Modify your last program and try to make it work for any number type, 
// not just integer (e.g. decimal, float, byte, etc.). Use generic method 
// (read in Internet about generic methods in C#).

using System;

class GenericMethod
{
    // similar with the other functions
    static T FindProduct<T>(params T[] numbers) 
    {
        T product = (dynamic)1;

        foreach (var number in numbers)
        {
            product *= (dynamic)number;
        }

        return product;
    }


    static void Main()
    {
        // try int:
        Console.WriteLine(FindProduct<int>(1, 2, 3, 4));

        //try double (even without specifing the type):
        Console.WriteLine(FindProduct(1.3, 2.2, 3.3, 4.5, 5.8));

        //try float:
        Console.WriteLine(FindProduct(1.33f, 2.22f, 3.33f));

        //try decimal:
        Console.WriteLine(FindProduct(10.0m, 20.0m, 30.0m));
    }
}
